﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    /// <summary>
    /// 手动执行编码转换
    /// </summary>
    [CPPEI.WebApi.AuthPostAction("CCR", "ManualConvert", "1.0")]
    public class ManualConvertActionAction : BaseAction<ManualConvertActionParams, ManualConvertActionResult>
    {
        protected override ActionResult<ManualConvertActionResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            ManualConvertActionParams opParams)
        {
            SER.ManualService service = new SER.ManualService();
            ServiceResult result = service.ConvertCCR(context.UserId, opParams.TableId);
            if(result.IsSuccess)
            {
                return new ActionResult<ManualConvertActionResult>(new ManualConvertActionResult());
            }
            else
            {
                return new ActionResult<ManualConvertActionResult>(result.IsSuccess, result.ErrorCode, result.Message, null);
            }
        }
    }

    public class ManualConvertActionParams
    {
        /// <summary>
        /// 数据表编号
        /// </summary>
        [Parameter]
        public Guid TableId { get; set; }
    }

    public class ManualConvertActionResult
    {
    }
}
